package Leetcode第一期;

public class 替换空格_5 {
    public String replaceSpace(String s) {
        StringBuilder sb=new StringBuilder();
        for(int i=0;i<s.length();i++){
            char ch=s.charAt(i);
            if(ch==' ') {
                sb.append("%20");
            } else {
                sb.append(ch);
            }
        }
        return sb.toString();
    }

    public String replaceSpaceA(String s) {
        StringBuilder sb=new StringBuilder();

        for(int i=0;i<s.length();i++){
            if (s.charAt(i)==' '){
                sb.append("%20");
            }else{
                sb.append(s.charAt(i));
            }
        }

        return sb.toString();
    }


}
